
package com.scalar.chiptrack.operations.packingslip.forms;

import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;

import com.scalar.chiptrack.ChipTrackActionForm;
import com.scalar.chiptrack.commons.Address;
import com.scalar.chiptrack.commons.ClientInfo;
import com.scalar.chiptrack.utils.StringUtils;

public class PackingSlipForm extends ChipTrackActionForm {

	private String 	m_label = null;
	private int 	m_customerShippingId = -1;
	private int 	m_salesOrderId = -1;
	private String 	m_salesOrderNumber = null;
	private String 	m_customerName = null;
	private String 	m_customerPO = null;
	private String 	m_contactPerson = null;
	private String 	m_repOffice = null;
	private String 	m_weight = "";
	private String 	m_terms = null;
	private String 	m_fob = null;
	private String 	m_noOfBoxes = null;
	private String 	m_tracking[] = null;
	private String 	m_shippedVia = null;
	private String 	m_shippingMethod = null;
	private String 	m_shippingAccount = null;
	private String 	m_billingAddress = null;
	private String 	m_shippingAddress = null;
	private String 	m_shippingInstructions = null;
	private String m_comments = null ;
	private static String m_clientName = "";
	private int 	m_shippingToAddressId = -1;
	private int 	m_billingAddressId = -1;
	private int 	m_shippingFromAddressId = -1;
	private int 	m_shippingFromLocationId = -1;
	private HashMap m_lineItems = null;
	private HashMap m_finalInventoryDataMap = null;
	private Date 	m_generatedDate = null;
	private String 	m_status = null;
	private Address m_billingAddressObject = null;
	private Address m_shippingAddressObject = null;
    private Address newShippingAddress = null;
    private int newShippingAddressId = -1;
    private int newBillingAddressId = -1;
    private int newHiddenShippingAddressId = -1;
	private String 	m_shipDate = null;
	private String 	m_invNo = null;
	
	private String  m_action = null;
	private int  	m_otherCustomerShippingId = -1;
	private ArrayList lineItems = null;
	private boolean dropShippment = false;
	private ClientInfo clientInfo = null;
		
	private boolean confrimPackingSlip = false;	
	private boolean cancelPackingSlip  = false;

    private int m_cstRandomKey = -1;
    private String customerNumber = null;
    private String recipientType = null;

    private String mPaletteCount = null;

    private String mPackedby = null;
    private String mTitle = null;

    // Variables for WebLs
    private String vendorName = null;
    private String vendorNumber = null;

    private String supplierNumber = null;
    private String odmSupplierNumber = null;
    private String odm = null;
    private int    odmId = -1;
    private String responseStatus = null;

    private HashMap finalInventoryDataMapView = null;

    private Address m_shippersAddressObject = null;
    private String  freightInstructions = null;
    private String  letterOfCreditNo = null;
    private Address shippingVendorAddressObject = null;
    private boolean isConsignment;
    private boolean isSample = false;
    private String weightType       = null;
    private String uomPkgDimension  = null;

    private String packageDimension     = null;
    private String grossWeight          = null;
    private String countryOfFabOrigin   = null;
    private String countryOfAssyOrigin  = null;
    private String flightNumberOne      = null;
    private String flightNumberTwo      = null;
    private String etd                  = null;
    private String eta                  = null;
    private String hawb                 = null;
    private String mawb                 = null;
    private String airWayBillNo         = null;


    public boolean getIsSample()
    {
        return isSample;
    }
    public void setIsSample( boolean isSample )
    {
        this.isSample = isSample;
    }
        

    public HashMap getFinalInventoryDataMapView() {
        return finalInventoryDataMapView;
    }

    public void setFinalInventoryDataMapView(HashMap finalInventoryDataMapView) {
        this.finalInventoryDataMapView = finalInventoryDataMapView;
    }

	public PackingSlipForm () {}

  	public PackingSlipForm (String label,
							  int customerShippingId,
							  int salesOrderId,
							  String salesOrderNumber,
							  String customerName,
							  String customerPO,
							  String contactPerson,
							  String repOffice,
							  String terms,
							  String fob,
							  String noOfBoxes,
							  String tracking[],
							  String shippedVia,
							  String shippingMethod,
							  String shippingAccount,
							  String billingAddress,
							  String shippingAddress,
							  String shippingInstructions,
		                       String comments,
		                      Address billingAddressObject,
		                      Address shippingAddressObject   ) {

		m_label = label;
		m_customerShippingId = customerShippingId;
		m_salesOrderId = salesOrderId;
		m_salesOrderNumber = salesOrderNumber;
		m_customerName = customerName;
		m_customerPO = customerPO;
		m_contactPerson = contactPerson;
		m_repOffice = repOffice;
		m_terms = terms;
		m_fob = fob;
		m_noOfBoxes = noOfBoxes;
		m_tracking = tracking;
		m_shippedVia = shippedVia;
		m_shippingMethod = shippingMethod;
		m_shippingAccount = shippingAccount;
		m_billingAddress = billingAddress;
		m_shippingAddress = shippingAddress;
		m_shippingInstructions = shippingInstructions;
		m_billingAddressObject = billingAddressObject;
		m_shippingAddressObject = shippingAddressObject;
		m_comments  = comments;      
	}

	public PackingSlipForm (String label,
							  int customerShippingId,
							  int salesOrderId,
							  String salesOrderNumber,
							  String customerName,
							  String customerPO,
							  String contactPerson,
							  String repOffice,
							  String terms,
							  String fob,
							  String noOfBoxes,
							  String tracking[],
							  String shippedVia,
							  String shippingMethod,
							  String shippingAccount,
							  String billingAddress,
							  String shippingAddress,
							  String shippingInstructions
		                         ) {

		m_label = label;
		m_customerShippingId = customerShippingId;
		m_salesOrderId = salesOrderId;
		m_salesOrderNumber = salesOrderNumber;
		m_customerName = customerName;
		m_customerPO = customerPO;
		m_contactPerson = contactPerson;
		m_repOffice = repOffice;
		m_terms = terms;
		m_fob = fob;
		m_noOfBoxes = noOfBoxes;
		m_tracking = tracking;
		m_shippedVia = shippedVia;
		m_shippingMethod = shippingMethod;
		m_shippingAccount = shippingAccount;
		m_billingAddress = billingAddress;
		m_shippingAddress = shippingAddress;
		m_shippingInstructions = shippingInstructions;		
	}

	public ActionErrors validate( ActionMapping mapping, HttpServletRequest request ) 
	{
		ActionErrors errors = new ActionErrors(  );
 
		if ( ( getNoOfBoxes() != null ) && ( getNoOfBoxes().trim().length() != 0 ) ) 
		{
			try
			{
				Integer.parseInt ( getNoOfBoxes() );
			}
			catch ( Exception e )
			{
				errors.add( "No of Boxes ", new ActionError("No of Boxes can have only a integer values ") );				
			}
		}
		return errors;
	}


	public void reset( ActionMapping mapping, HttpServletRequest request ) 
	{
		m_otherCustomerShippingId = -1;
        newBillingAddressId = 0;
        m_tracking = new String[] {""};
		confrimPackingSlip	= false;
		cancelPackingSlip 	= false;
		if( lineItems == null || lineItems.isEmpty() == true )
		{
			lineItems = new ArrayList();
		}
		
		if(  m_finalInventoryDataMap == null || m_finalInventoryDataMap.isEmpty() == true )
		{
			m_finalInventoryDataMap = new HashMap();
		}
	}

	public String getLabel() {
		return m_label;
	}

	public void setLabel (String label) {
		m_label = label;
	}

	public int getCustomerShippingId() {
		return m_customerShippingId;
	}

	public void setCustomerShippingId (int customerShippingId) {
		m_customerShippingId = customerShippingId;
	}

	public int getSalesOrderId() {
		return m_salesOrderId;
	}

	public void setSalesOrderId (int salesOrderId) {
		m_salesOrderId = salesOrderId;
	}

	public String getSalesOrderNumber() {
		return m_salesOrderNumber;
	}
    public void setComments ( String comments )
    {
	 m_comments = comments;
    }
    public  String getComments ( )
    {
	   return m_comments;
    }

	public void setSalesOrderNumber (String salesOrderNumber) {
		m_salesOrderNumber = salesOrderNumber;
	}

	public String getCustomerName() {
		return m_customerName;
	}
	public void setCustomerName (String customerName) {
		m_customerName = customerName;
	}

	public String getCustomerPO() {
		return m_customerPO;
	}
	public void setCustomerPO (String customerPO) {
		m_customerPO = customerPO;
	}

	public String getContactPerson() {
		return m_contactPerson;
	}
	public void setContactPerson (String contactPerson) {
		m_contactPerson = contactPerson;
	}

	public String getRepOffice() {
		return m_repOffice;
	}
	public void setRepOffice (String repOffice) {
		m_repOffice = repOffice;
	}

	public String getWeight() 
	{		
		return getFormatedWeight( m_weight );
	}

    public double getWeightAsDouble()
	{  
		double weight = 0;
	   	try
	    {
	    	weight = new Double( m_weight ).doubleValue();
		} 
        catch(NumberFormatException ne )
	    {   System.out.println( ne ); }
        finally 
	    { 
			
        }
        return weight;
	}	

	public void setWeight (String weight) 
	{
		m_weight = getFormatedWeight( weight );
	}

	public String getFormatedWeight( String weght )
	{
		String weight = weght;		  
		if ( weight != null )
	   	{   
	   		if( weight.equals("0.0") || weight.equals("0.00") )
	   		{
				weight = "";
	   		}
		}
		if (  weight != null && weight.trim().length() > 0 )
		{
			DecimalFormat df = new DecimalFormat ("########.00");
            weight =  df.format((new Double(weight).doubleValue() ));		   
		}
		else
		{   
			weight = ""; 
		}
		return weight;
    }

	public void setTermsForHtmlView(String terms)
	{
		m_fob = terms;
	}

	public String getTermsForHtmlView()
	{
		if( ( m_fob == null ) || ( m_fob.trim().length() == 0 ) )
		{
			m_fob = "";
		}
		return m_fob;
	}

	public String getTerms() 
	{
		return m_terms;
	}
	public void setTerms (String terms) {
		m_terms = terms;
	}

	public String getFob() {
		return m_fob;
	}
	public void setFob (String fob) {
		m_fob = fob;
	}

	public String getNoOfBoxesForHtmlView()
	{
		if( ( m_noOfBoxes == null ) || ( m_noOfBoxes.trim().length() == 0 ) ||
									   ( "0".equalsIgnoreCase( m_noOfBoxes ) ) )
		{
			m_noOfBoxes = "";
		}

		return m_noOfBoxes;
	}

	public void setNoOfBoxesForHtmlView(String noOfBoxes)
	{
		m_noOfBoxes=noOfBoxes;
	}

	public String getNoOfBoxes() {
		return m_noOfBoxes;
	}

	public int getNoOfBoxesAsInt() {
		int noOfBoxes = 0;
		try {
			noOfBoxes = Integer.parseInt (m_noOfBoxes);
		}
		catch (NumberFormatException nfe) {
			// invalid
		}
		return noOfBoxes;
	}

	public void setNoOfBoxes (String noOfBoxes) {
		m_noOfBoxes = noOfBoxes;
	}

	public String getTrackingAsString()
	{
		return StringUtils.concatStrings( m_tracking, ";" );
	}

	public String[] getTracking()
	{
		return m_tracking;
	}

	public void setTracking( String[] tracking )
	{
		m_tracking = tracking;
	}

	public String getShippedVia() {
		return m_shippedVia;
	}
	public void setShippedVia (String shippedVia) {
		m_shippedVia = shippedVia;
	}

	 public String getShippingMethod() {
		 return m_shippingMethod;
	 }

	 public void setShippingMethod (String shippingMethod) {
		 m_shippingMethod = shippingMethod;
	 }

	 public String getShippingAccount() {
		 return m_shippingAccount;
	 }

	 public void setShippingAccount (String shippingAccount) {
		 m_shippingAccount = shippingAccount;
	 }

	public String getBillingAddress() {
		return m_billingAddress;
	}

	public void setBillingAddress (String billingAddress) {
		m_billingAddress = billingAddress;
	}

	public String getShippingAddress() {
		return m_shippingAddress;
	}
	public void setShippingAddress (String shippingAddress) {
		m_shippingAddress = shippingAddress;
	}

	public String getShippingInstructions() {
		return m_shippingInstructions;
	}

    public String getShippingInstructionsObjectFormatted()
    {
		return formatLines( m_shippingInstructions, 50);
	}

	public void setShippingInstructions (String shippingInstructions) {
		m_shippingInstructions = shippingInstructions;
	}

	public int getShippingToAddressId() {
		return m_shippingToAddressId;
	}

	public void setShippingToAddressId (int shippingToAddressId) {
		m_shippingToAddressId = shippingToAddressId;
	}

	public int getBillingAddressId() {
		return m_billingAddressId;
	}

	public void setBillingAddressId (int billingAddressId) {
		m_billingAddressId = billingAddressId;
	}

	public int getShippingFromAddressId() {
		return m_shippingFromAddressId;
	}

	public void setShippingFromAddressId (int shippingFromAddressId) {
		m_shippingFromAddressId = shippingFromAddressId;
	}

	public int getShippingFromLocationId() {
		return m_shippingFromLocationId;
	}

	public void setShippingFromLocationId (int shippingFromLocationId) {
		m_shippingFromLocationId = shippingFromLocationId;
	}

	public HashMap getLineItemMap() {
		return m_lineItems;
	}

	public void setLineItemMap (HashMap lineItems) {
		m_lineItems = lineItems;
	}

	public HashMap getFinalInventoryDataMap() {
		return m_finalInventoryDataMap;
	}

	public void setFinalInventoryDataMap (HashMap finalInventoryDataMap) {
		m_finalInventoryDataMap = finalInventoryDataMap;
	}

	public Date getGeneratedDate() {
		return m_generatedDate;
	}

	public void setGeneratedDate (Date generatedDate) {
		m_generatedDate = generatedDate;
	}

	public String getStatus() {
		return m_status;
	}

	public void setStatus (String status) {
		m_status = status;
	}

	public Address getBillingAddressObject() {
		return m_billingAddressObject;
	}

	public void setBillingAddressObject (Address billingAddressObject) {
		m_billingAddressObject = billingAddressObject;
	}

	public Address getShippingAddressObject() {
		return m_shippingAddressObject;
	}

	public void setShippingAddressObject (Address shippingAddressObject) {
		m_shippingAddressObject = shippingAddressObject;
	}

	public String getShipDate() {
		return m_shipDate;
	}

	public void setShipDate (String shipDate) {
		m_shipDate = shipDate;
	}

	public String getInvNo() {
		return m_invNo;
	}

	public void setInvNo(String invNo) {
		m_invNo = invNo;
	}
    
	public String getAction()
	{
		return m_action;
	}

	public void setAction( String action )
	{
		m_action = action;
	}

	public int getOtherCustomerShippingId()
	{
		return m_otherCustomerShippingId;
	}

	public void setOtherCustomerShippingId( int customerShippingId )
	{
		m_otherCustomerShippingId = customerShippingId;
	}

	public ArrayList getLineitems()
	{
		return lineItems;
	}

	public void setLineitems( ArrayList list )
	{
		lineItems = list;
	}

	public boolean isDropShippment()
	{
		return dropShippment;
	}

	public void setDropShippment( boolean b )
	{
		dropShippment = b;
	}
    
	public String getShippingAddressObjectFormatted()
    {	 
		return m_shippingAddressObject.getAddressAsHTML();//getFormattedAddress( m_shippingAddressObject );
	}

    public String getShippingVendorObjectFormatted()
    {
		return getFormattedAddress( shippingVendorAddressObject );
	}

    public String getShippingAddressObjectFormattedAirgo()
	{
		StringBuffer formatedAddress = new StringBuffer();
        if ( odm != null && odm.trim().length() > 0 )
        {
             if( m_shippingAddressObject != null && m_shippingAddressObject.getContactPerson() != null && !m_shippingAddressObject.getContactPerson().equalsIgnoreCase( odm ) )
            {
                if( odm != null && odm.trim().length() > 0 )
                {
                    formatedAddress.append( odm );
                    if( m_shippingAddressObject != null && ( m_shippingAddressObject.getContactPerson() != null ) && ( m_shippingAddressObject.getContactPerson().trim().length() > 0 ) )
                    {
                        formatedAddress.append( "<BR>" );
                    }
                    formatedAddress.append( m_shippingAddressObject.getContactPerson() );

                    if( m_shippingAddressObject != null && ( ( ( m_shippingAddressObject.getAddress1() != null ) && ( m_shippingAddressObject.getAddress1().trim().length() > 0 ) ) || ( ( m_shippingAddressObject.getAddress2() != null ) && ( m_shippingAddressObject.getAddress2().trim().length() > 0 ) ) ) )
                    {
                        formatedAddress.append( "<BR>" );
                    }
                }
                else
                {
                    formatedAddress.append( m_shippingAddressObject.getContactPerson() );
                    if( m_shippingAddressObject != null && ( ( ( m_shippingAddressObject.getAddress1() != null ) && ( m_shippingAddressObject.getAddress1().trim().length() > 0 ) ) || ( ( m_shippingAddressObject.getAddress2() != null ) && ( m_shippingAddressObject.getAddress2().trim().length() > 0 ) ) ) )
                    {
                        formatedAddress.append( "<BR>" );
                    }
                }
            }
            else
            {
                if( odm != null && odm.trim().length() > 0 )
                {
                    formatedAddress.append( odm );
                    if( m_shippingAddressObject != null && ( ( ( m_shippingAddressObject.getAddress1() != null ) && ( m_shippingAddressObject.getAddress1().trim().length() > 0 ) ) || ( ( m_shippingAddressObject.getAddress2() != null ) && ( m_shippingAddressObject.getAddress2().trim().length() > 0 ) ) ) )
                    {
                        formatedAddress.append( "<BR>" );
                    }
                }
            }
        }
        else
        {
            if( m_shippingAddressObject != null && m_shippingAddressObject.getContactPerson() != null && !m_shippingAddressObject.getContactPerson().equalsIgnoreCase( m_customerName ) )
            {
                if( m_customerName != null && m_customerName.trim().length() > 0 )
                {
                    formatedAddress.append( m_customerName );
                    if( m_shippingAddressObject != null && ( m_shippingAddressObject.getContactPerson() != null ) && ( m_shippingAddressObject.getContactPerson().trim().length() > 0 ) )
                    {
                        formatedAddress.append( "<BR>" );
                    }
                    formatedAddress.append( m_shippingAddressObject.getContactPerson() );

                    if( m_shippingAddressObject != null && ( ( ( m_shippingAddressObject.getAddress1() != null ) && ( m_shippingAddressObject.getAddress1().trim().length() > 0 ) ) || ( ( m_shippingAddressObject.getAddress2() != null ) && ( m_shippingAddressObject.getAddress2().trim().length() > 0 ) ) ) )
                    {
                        formatedAddress.append( "<BR>" );
                    }
                }
                else
                {
                    formatedAddress.append( m_shippingAddressObject.getContactPerson() );
                    if( m_shippingAddressObject != null && ( ( ( m_shippingAddressObject.getAddress1() != null ) && ( m_shippingAddressObject.getAddress1().trim().length() > 0 ) ) || ( ( m_shippingAddressObject.getAddress2() != null ) && ( m_shippingAddressObject.getAddress2().trim().length() > 0 ) ) ) )
                    {
                        formatedAddress.append( "<BR>" );
                    }
                }
            }
            else
            {
                if( m_customerName != null && m_customerName.trim().length() > 0 )
                {
                    formatedAddress.append( m_customerName );
                    if( m_shippingAddressObject != null && ( ( ( m_shippingAddressObject.getAddress1() != null ) && ( m_shippingAddressObject.getAddress1().trim().length() > 0 ) ) || ( ( m_shippingAddressObject.getAddress2() != null ) && ( m_shippingAddressObject.getAddress2().trim().length() > 0 ) ) ) )
                    {
                        formatedAddress.append( "<BR>" );
                    }
                }
            }
        }

		formatedAddress.append( getFormattedAddressAirgo( m_shippingAddressObject ) );
		return formatedAddress.toString();
	}

	public String getLabelShippingAddressObjectFormatted() // added by neelima
	{
		return getFormattedAddress( m_shippingAddressObject, "label" );
	}

	public String getShippingAddressXMLFormatted()
	{
		return getXMLFormattedAddress( m_shippingAddressObject );
	}

	public String getShippingAddressXMLFormattedAirgo()
	{
		return getXMLFormattedAddressAirgo( m_shippingAddressObject );
	}

    public String getBillingAddressObjectFormatted()
    {
		return m_billingAddressObject.getAddressAsHTML();//getFormattedAddress( m_billingAddressObject );
	}
	public String getBillingAddressObjectFormattedAirgo()
	{
		StringBuffer formatedAddress = new StringBuffer(); 
		if( m_billingAddressObject != null && m_billingAddressObject.getContactPerson() != null && !m_billingAddressObject.getContactPerson().equalsIgnoreCase( m_customerName ) )
		{
			if( m_customerName != null && m_customerName.trim().length() > 0 )
			{
				formatedAddress.append( m_customerName );
				if( m_billingAddressObject != null && ( m_billingAddressObject.getContactPerson() != null ) && ( m_billingAddressObject.getContactPerson().trim().length() > 0 ) )
				{
					formatedAddress.append( "<BR>" );
				}
				formatedAddress.append( m_billingAddressObject.getContactPerson() );
				
				if( m_billingAddressObject != null && ( ( ( m_billingAddressObject.getAddress1() != null ) && ( m_billingAddressObject.getAddress1().trim().length() > 0 ) ) || ( ( m_billingAddressObject.getAddress2() != null ) && ( m_billingAddressObject.getAddress2().trim().length() > 0 ) ) ) )
				{ 
					formatedAddress.append( "<BR>" );
				}
			}
			else
			{
				formatedAddress.append( m_billingAddressObject.getContactPerson() );
				if( m_billingAddressObject != null && ( ( ( m_billingAddressObject.getAddress1() != null ) && ( m_billingAddressObject.getAddress1().trim().length() > 0 ) ) || ( ( m_billingAddressObject.getAddress2() != null ) && ( m_billingAddressObject.getAddress2().trim().length() > 0 ) ) ) )
				{ 
					formatedAddress.append( "<BR>" );
				}
			}
		}
		else
		{
			if( m_customerName != null && m_customerName.trim().length() > 0 )
			{
				formatedAddress.append( m_customerName );
				if( m_billingAddressObject != null && ( ( ( m_billingAddressObject.getAddress1() != null ) && ( m_billingAddressObject.getAddress1().trim().length() > 0 ) ) || ( ( m_billingAddressObject.getAddress2() != null ) && ( m_billingAddressObject.getAddress2().trim().length() > 0 ) ) ) )
				{ 
					formatedAddress.append( "<BR>" );
				}
			}
		}
		formatedAddress.append( getFormattedAddressAirgo( m_billingAddressObject ) );
		return formatedAddress.toString();
	}
	
	public String getFormattedClientAddress( Address add )
	{
		StringBuffer formatAddress = new StringBuffer();

        formatAddress.append ( ( ( add.getContactPerson() == null ) || ( ( add.getContactPerson().trim().length() == 0 ) ) ) ? "" :"<BR>" +  add.getContactPerson() );
		formatAddress.append ( ( ( add.getAddress1() == null ) || ( ( add.getAddress1().trim().length() == 0 ) ) ) ? "" :"<BR>" +  add.getAddress1() );
		formatAddress.append ( ( ( add.getAddress2() == null ) || ( ( add.getAddress2().trim().length() == 0 ) ) ) ? "" :"<BR>" + add.getAddress2() );
		formatAddress.append ( ( ( add.getAddress3() == null ) || ( ( add.getAddress3().trim().length() == 0 ) ) ) ? "" : "<BR>" + add.getAddress3() );
		formatAddress.append ( ( ( add.getAddress4() == null ) || ( ( add.getAddress4().trim().length() == 0 ) ) ) ? "" : "<BR>" + add.getAddress4() );
		formatAddress.append ( ( ( add.getCity() == null ) || ( add.getCity().trim().length()==0 ) ) ? "" : "<BR>" +  add.getCity() );
		String formatState = PackingSlipForm.getFormatedState(add);
		if ( formatState.trim().length() !=0 )
		   formatAddress.append ("<br>"+formatState); 
        formatAddress.append ( ( ( add.getPhoneNumber() != null ) && ( add.getPhoneNumber().trim().length() > 0 ) ) ?  "<BR><BR>Tel: "+ add.getPhoneNumber() : ""  );
		formatAddress.append ( ( ( add.getFaxNumber() != null ) && ( add.getFaxNumber().trim().length() > 0 ) ) ?  "<BR>Fax: "+ add.getFaxNumber() : "");
        formatAddress.append ( ( ( add.getEmail() != null ) && ( add.getEmail().trim().length() > 0 ) ) ?  "<BR>Email: "+ add.getEmail() : "" );

		return formatAddress.toString() ;
	}
	
	public String getFormattedAddressAirgo( Address add )
	{
		StringBuffer formatAddress = new StringBuffer();
		
		if( add != null )
		{
			if( add.getAddress1() != null )
			formatAddress.append ( add.getAddress1() );
			
			if( add.getAddress1() != null && !( add.getAddress1().trim().length() == 0 ) && add.getAddress2() != null && !( add.getAddress2().trim().length() == 0 ) )
			formatAddress.append ( ", " );
			
			if( add.getAddress2() != null )
			formatAddress.append ( add.getAddress2() ); 
	
			if( ( add.getAddress3() != null && !add.getAddress3().trim().equalsIgnoreCase( "" ) ) || ( add.getAddress4() != null && !add.getAddress4().trim().equalsIgnoreCase( "" ) ) )
			formatAddress.append ( "<BR>" );
			
			if( add.getAddress3() != null )
			formatAddress.append ( add.getAddress3 () );
			
			if( add.getAddress3() != null && !add.getAddress3().trim().equalsIgnoreCase( "" ) && add.getAddress4() != null && !add.getAddress4().trim().equalsIgnoreCase( "" ) )
			formatAddress.append ( ", " );
			
			if( add.getAddress4() != null )
			formatAddress.append ( add.getAddress4() ); 
			
			StringBuffer cityStateZip = new StringBuffer ( "" );
	
			if ( add.getCity()!= null && !( "".equals( add.getCity().trim() ) ) ) cityStateZip.append ( add.getCity().trim() );
			
			// add ',' only if city, state, zip are not empty  
			if ( add.getCity() != null && !( "".equals( add.getCity().trim() ) ) && ( ( add.getState() != null && !( "".equals( add.getState().trim() ) ) ) || ( add.getZipCode() != null && !( "".equals( add.getZipCode().trim() ) ) ) ) ) cityStateZip.append ( ", " );
			
			if ( add.getState() != null && !( "".equals( add.getState().trim() ) ) ) cityStateZip.append( add.getState().trim() );
			
			// Add '-' only if there is state and Zip also
			if ( add.getState() != null && !"".equals( add.getState().trim() ) && add.getZipCode() != null && !"".equals( add.getZipCode ().trim() ) ) cityStateZip.append ( " - " );
			if ( add.getZipCode() != null && !"".equals( add.getZipCode().trim() ) ) cityStateZip.append ( add.getZipCode().trim() );
			// add ',' if any of the above is present
			if ( ( ( add.getCity() != null && !"".equals( add.getCity().trim() ) ) || ( add.getState() != null && !"".equals( add.getState().trim() ) ) || ( add.getZipCode() != null && !"".equals( add.getZipCode().trim() ) ) ) && ( add.getCountry() != null && !"".equalsIgnoreCase( add.getCountry().trim() ) ) ) cityStateZip.append ( ", " );
			
			if( add.getCountry() != null )
			cityStateZip.append ( add.getCountry().trim() );
	
			if( cityStateZip.toString().trim().length() > 0  )
			{
				formatAddress.append ( "<BR>" + cityStateZip );	
			}
	
			StringBuffer phFax = new StringBuffer ();
			if( add.getPhoneNumber() != null && !"".equals( add.getPhoneNumber().trim() ) ) phFax.append ( "T:" + add.getPhoneNumber().trim() );
			if( add.getPhoneNumber() != null && !"".equals( add.getPhoneNumber().trim() ) && add.getFaxNumber() != null && !"".equals( add.getFaxNumber().trim() ) ) phFax.append ( ",&nbsp;" );
			
			if( add.getFaxNumber() != null && !"".equals( add.getFaxNumber().trim() ) ) phFax.append ( "F:" + add.getFaxNumber().trim() );
			
			if( phFax.toString().trim().length() > 0  )
			{
				formatAddress.append ( "<BR>" + phFax );	
			}
			
			if(  add.getEmail() != null && add.getEmail().trim().length() > 0 )
			{
				formatAddress.append ( "<BR>Email:" + add.getEmail().trim() );
			}
		}
		return formatAddress.toString() ;
	}

	public static String getFormatedState( Address add )
	{	
	    String addr = "";
        if (  add.getState() != null  &&  add.getState().trim().length() != 0 )
		    addr =  add.getState();
		if( add.getZipCode() != null &&  add.getZipCode().trim().length() != 0 )
		{           
		     if ( addr.trim().length() !=0 )
		         addr = addr + "&nbsp;-&nbsp;" + add.getZipCode();
		    else
				 addr = addr + add.getZipCode();
		}
		if( add.getCountry() != null && add.getCountry().trim().length() != 0 )
	    {
	        if ( addr.trim().length() != 0 )
			    addr = addr + ",&nbsp;" + add.getCountry();
			else
			    addr = addr + add.getCountry();
	   	}  					     

		return addr;
	}

    public static String getFormatedCityState( Address add )
	{
	    String addr = "";
        if( add.getCity() != null && add.getCity() .trim() .length() != 0 )
            addr = add.getCity() + ",&nbsp;" ;
        if (  add.getState() != null  &&  add.getState().trim().length() != 0 )
		    addr =  addr  + add.getState();
		if( add.getZipCode() != null &&  add.getZipCode().trim().length() != 0 )
		{
		     if ( addr.trim().length() !=0 )
		         addr = addr + "&nbsp;-&nbsp;" + add.getZipCode();
		    else
				 addr = addr + add.getZipCode();
		}
		if( add.getCountry() != null && add.getCountry().trim().length() != 0 )
	    {
	        if ( addr.trim().length() != 0 )
			    addr = addr + ",&nbsp;" + add.getCountry();
			else
			    addr = addr + add.getCountry();
	   	}

		return addr;
	}

	public static String getFormatedStateXPDL ( Address add )
	{
		String addr = getFormatedState(add);
		String  temp = addr.replaceAll("&nbsp;"," ");
		return temp;
	}

    public static String getFormatedCityStateXPDL ( Address add )
	{
		String addr = getFormatedCityState(add);
		String  temp = addr.replaceAll("&nbsp;"," ");
		return temp;
	}

	public static String getFormattedAddress( Address add )
	{
		StringBuffer formatAddress = new StringBuffer();
        formatAddress.append ( ( ( add.getContactPerson() == null ) || ( ( add.getContactPerson().trim().length() == 0 ) ) ) ? "" :"<BR>C/O " +  add.getContactPerson() );
		formatAddress.append ( ( ( add.getAddress1() == null ) || ( ( add.getAddress1().trim().length() == 0 ) ) ) ? "" :"<BR>" +  add.getAddress1() );
		   		
		formatAddress.append ( ( ( add.getAddress2() == null ) || ( ( add.getAddress2().trim().length() == 0 ) ) ) ? "" :"<BR>" + add.getAddress2() );

		formatAddress.append ( ( ( add.getAddress3() == null ) || ( ( add.getAddress3().trim().length() == 0 ) ) ) ? "" : "<BR>" + add.getAddress3() );

		formatAddress.append ( ( ( add.getAddress4() == null ) || ( ( add.getAddress4().trim().length() == 0 ) ) ) ? "" : "<BR>" + add.getAddress4() );

		formatAddress.append ( ( ( add.getCity() == null ) || ( add.getCity().trim().length()==0 ) ) ? "" : "<BR>" +  add.getCity() );

		String formatedState = PackingSlipForm.getFormatedState( add );
		if ( formatedState.trim().length() > 0 )
        	formatAddress.append ( "<br>" + formatedState ); 

        formatAddress.append ( ( ( add.getPhoneNumber() != null ) && ( add.getPhoneNumber().trim().length() > 0 ) ) ?  "<BR><BR>Tel: "+ add.getPhoneNumber() : "" );
        formatAddress.append ( ( ( add.getCellNumber() != null ) && ( add.getCellNumber().trim().length() > 0 ) ) ? "<BR>Cell No: "+ add.getCellNumber() : "");
        formatAddress.append ( ( ( add.getFaxNumber() != null ) && ( add.getFaxNumber().trim().length() > 0 ) ) ?  "<BR>Fax: "+ add.getFaxNumber() : "" );
        formatAddress.append ( ( ( add.getEmail() != null ) && ( add.getEmail().trim().length() > 0 ) ) ?  "<BR>Email: "+ add.getEmail() : "" );


		return formatAddress.toString() ;
	}

	public String getLabelFormattedClient( Address add  )
	{
		StringBuffer formatAddress = new StringBuffer();
		
		formatAddress.append ( ( ( add.getAddress1() == null ) || ( ( add.getAddress1().trim().length() == 0 ) ) ) ? "" :"<BR>" +  add.getAddress1() );  		
		formatAddress.append ( ( ( add.getAddress2() == null ) || ( ( add.getAddress2().trim().length() == 0 ) ) ) ? "" :"&nbsp;" + add.getAddress2() );
		formatAddress.append ( ( ( add.getAddress3() == null ) || ( ( add.getAddress3().trim().length() == 0 ) ) ) ? "" : "&nbsp;" + add.getAddress3() );   		
		formatAddress.append ( ( ( add.getAddress4() == null ) || ( ( add.getAddress4().trim().length() == 0 ) ) ) ? "" : "&nbsp;" + add.getAddress4() );
		formatAddress.append ( ( ( add.getCity() == null ) || ( add.getCity().trim().length()==0 ) ) ? "" : "<BR>" +  add.getCity()+"," );
		formatAddress.append ( ( ( add.getState() == null ) || ( add.getState().trim().length()==0 ) ) ? "" : "&nbsp;" +  add.getState());
		formatAddress.append ( ( ( add.getCountry() == null ) || ( add.getCountry().trim().length()==0 ) ) ? "" : "&nbsp;" +  add.getCountry());
		formatAddress.append ( ( ( add.getZipCode() == null ) || ( add.getZipCode().trim().length()==0 ) ) ? "" : "&nbsp;" +  add.getZipCode());
		
		return formatAddress.toString() ;
	}


	public String getFormattedAddress( Address add , String label )
	{
		StringBuffer formatAddress = new StringBuffer();
		formatAddress.append ( ( ( add.getAddress1() == null ) || ( ( add.getAddress1().trim().length() == 0 ) ) ) ? "" :"<BR>" +  add.getAddress1() );		
		formatAddress.append ( ( ( add.getAddress2() == null ) || ( ( add.getAddress2().trim().length() == 0 ) ) ) ? "" :"<BR>" + add.getAddress2() );
		formatAddress.append ( ( ( add.getAddress3() == null ) || ( ( add.getAddress3().trim().length() == 0 ) ) ) ? "" : "<BR>" + add.getAddress3() );   		
		formatAddress.append ( ( ( add.getAddress4() == null ) || ( ( add.getAddress4().trim().length() == 0 ) ) ) ? "" : "<BR>" + add.getAddress4() );
		return formatAddress.toString() ;
	}

	public static String getXMLFormattedAddress( Address add )
	{
		StringBuffer formatAddress = new StringBuffer();
        formatAddress.append( "<contactPerson><![CDATA[" );
        formatAddress.append ( ( ( add.getContactPerson() == null ) || ( ( add.getContactPerson().trim().length() == 0 ) ) ) ? "" : add.getContactPerson() );
        formatAddress.append( "]]></contactPerson>" );

		formatAddress.append( "<address1><![CDATA[" );
		formatAddress.append ( ( ( add.getAddress1() == null ) || ( ( add.getAddress1().trim().length() == 0 ) ) ) ? "" : add.getAddress1() );
		
  		formatAddress.append ( "]]></address1> \n" );
        formatAddress.append( "<address2><![CDATA[" );
		formatAddress.append ( ( ( add.getAddress2() == null ) || ( ( add.getAddress2().trim().length() == 0 ) ) ) ? "" : add.getAddress2() );
   		
        formatAddress.append ( "]]></address2> \n" );
        formatAddress.append( "<address3><![CDATA[" );
		formatAddress.append ( ( ( add.getAddress3() == null ) || ( ( add.getAddress3().trim().length() == 0 ) ) ) ? "" : add.getAddress3() );
		formatAddress.append ( "]]></address3> \n" );
        formatAddress.append( "<address4><![CDATA[" );
		formatAddress.append ( ( ( add.getAddress4() == null ) || ( ( add.getAddress4().trim().length() == 0 ) ) ) ? "" : add.getAddress4() );
        formatAddress.append ( "]]></address4> \n" );
        formatAddress.append( "<city><![CDATA[" );
		formatAddress.append ( ( ( add.getCity() == null ) || ( add.getCity().trim().length()==0 ) ) ? "" : add.getCity() );
        formatAddress.append ( "]]></city> \n" );

		String formatedState = "";  
		formatedState = PackingSlipForm.getFormatedStateXPDL(add);
		if ( formatedState.trim().length() > 0 )
			formatAddress.append( "<state><![CDATA["+formatedState+"]]></state> \n" );

		formatAddress.append ( "<phone><![CDATA[" );
        formatAddress.append ( ( ( add.getPhoneNumber() != null ) && ( add.getPhoneNumber().trim().length() > 0 ) ) ?  "Tel: "+ add.getPhoneNumber()+"" : "");//modified by varma 06 jul 2004
		formatAddress.append ( "]]></phone> \n" );
		
		formatAddress.append ( "<fax><![CDATA[" );
        formatAddress.append ( ( ( add.getFaxNumber() != null ) && ( add.getFaxNumber().trim().length() > 0 ) ) ?  "Fax: "+ add.getFaxNumber() : "" );
		formatAddress.append ( "]]></fax> \n" );
        formatAddress.append ( "<cellno><![CDATA[" );
        formatAddress.append ( ( ( add.getCellNumber() != null ) && ( add.getCellNumber().trim().length() > 0 ) ) ?  "Cell No: "+ add.getCellNumber() : "");
        formatAddress.append ( "]]></cellno> \n" );
        formatAddress.append ( "<email><![CDATA[" );
        formatAddress.append ( ( ( add.getEmail() != null ) && ( add.getEmail().trim().length() > 0 ) ) ?  "Email: "+ add.getEmail() : "" );
        formatAddress.append ( "]]></email> \n" );

		return formatAddress.toString() ;
	}

    public static String getXMLFormattedClientAddress( Address add )
    {
        StringBuffer formatAddress = new StringBuffer();

        formatAddress.append( "<address1><![CDATA[" );
        formatAddress.append ( ( ( add.getAddress1() == null ) || ( ( add.getAddress1().trim().length() == 0 ) ) ) ? "" : add.getAddress1() );

        formatAddress.append ( "]]></address1> \n" );
        formatAddress.append( "<address2><![CDATA[" );
        formatAddress.append ( ( ( add.getAddress2() == null ) || ( ( add.getAddress2().trim().length() == 0 ) ) ) ? "" : add.getAddress2() );

        formatAddress.append ( "]]></address2> \n" );
        formatAddress.append( "<address3><![CDATA[" );
        formatAddress.append ( ( ( add.getAddress3() == null ) || ( ( add.getAddress3().trim().length() == 0 ) ) ) ? "" : add.getAddress3() );
        formatAddress.append ( "]]></address3> \n" );

        formatAddress.append( "<address4><![CDATA[" );
        formatAddress.append ( ( ( add.getAddress4() == null ) || ( ( add.getAddress4().trim().length() == 0 ) ) ) ? "" : add.getAddress4() );
        formatAddress.append ( "]]></address4> \n" );

        /*formatAddress.append( "<city><![CDATA[" );
        formatAddress.append ( ( ( add.getCity() == null ) || ( add.getCity().trim().length()==0 ) ) ? "" : add.getCity() );
        formatAddress.append ( "]]></city> \n" );*/
	    String formatedState = "";   
	    formatedState = PackingSlipForm.getFormatedCityStateXPDL(add);
		if ( formatedState.trim().length() > 0 )
		   formatAddress.append( "<state><![CDATA["+formatedState+"]]></state> \n" );

        formatAddress.append ( "<phone><![CDATA[" );
        formatAddress.append ( ( ( add.getPhoneNumber() != null ) && ( add.getPhoneNumber().trim().length() > 0 ) ) ?  "Tel: "+ add.getPhoneNumber()+"" : "" ); //modified by varma 06 jul 2004
        formatAddress.append ( "]]></phone> \n" );

        formatAddress.append ( "<fax><![CDATA[" );
        formatAddress.append ( ( ( add.getFaxNumber() != null ) && ( add.getFaxNumber().trim().length() > 0 ) ) ? "Fax: "+ add.getFaxNumber() : "" ); //modified by varma 06 jul 2004
        formatAddress.append ( "]]></fax> \n" );
	    formatAddress.append ( "<email><![CDATA[" );
        formatAddress.append ( ( ( add.getEmail() != null ) && ( add.getEmail().trim().length() > 0 ) ) ? "Email: "+ add.getEmail() : "" );     //modified by varma 06 jul 2004
        formatAddress.append ( "]]></email> \n" );

        return formatAddress.toString() ;
    }

	public String getXMLFormattedAddressAirgo( Address add )
	{
		StringBuffer formatAddress = new StringBuffer();

		formatAddress.append( "<address1><![CDATA[" );
		formatAddress.append ( ( ( add.getAddress1() == null ) || ( ( add.getAddress1().trim().length() == 0 ) ) ) ? "" : add.getAddress1() );
		
		if( add.getAddress1() != null && !( add.getAddress1().trim().length() == 0 ) && add.getAddress2() != null && !( add.getAddress2().trim().length() == 0 ) )
		formatAddress.append ( ", " );
		formatAddress.append ( add.getAddress2() ); 
		formatAddress.append ( "]]></address1> \n" );

		formatAddress.append ( "<address2><![CDATA[" + add.getAddress3 () );
		if( add.getAddress3() != null && !"".equalsIgnoreCase( add.getAddress3().trim() ) && add.getAddress4() != null && !"".equalsIgnoreCase( add.getAddress4().trim() ) )
		formatAddress.append ( ", " );
		formatAddress.append ( add.getAddress4() ); 
		formatAddress.append ( "]]></address2>" + "\n" );

		StringBuffer cityStateZip = new StringBuffer ( "" );

		if ( !"".equals( add.getCity () ) ) cityStateZip.append ( add.getCity () );
		// add ',' only if city, state, zip are not empty  
		if ( !"".equals( add.getCity () ) && ( !"".equals( add.getState() ) || !"".equals( add.getZipCode() ) ) ) cityStateZip.append ( ", " );
		if ( !"".equals( add.getState() ) ) cityStateZip.append ( add.getState () );
		// Add '-' only if there is state and Zip also
		if ( !"".equals( add.getState() ) && !"".equals( add.getZipCode() ) ) cityStateZip.append ( " - " );
		if ( !"".equals( add.getZipCode() ) ) cityStateZip.append ( add.getZipCode () );
		// add ',' if any of the above is present
		if ( ( !"".equals ( add.getCity() ) || !"".equals( add.getState() ) || !"".equals( add.getZipCode() ) ) && !"".equalsIgnoreCase( add.getCountry() ) ) cityStateZip.append ( ", " );
		cityStateZip.append ( add.getCountry () );

		formatAddress.append ( "<cityStateZip><![CDATA[" + cityStateZip + "]]></cityStateZip>" + "\n" );

		StringBuffer phFax = new StringBuffer ();
		if( !"".equals( add.getPhoneNumber() ) ) phFax.append( "T:" + add.getPhoneNumber () );
		if( !"".equals( add.getPhoneNumber() ) && !"".equals( add.getFaxNumber() ) ) phFax.append ( "," );
		if( !"".equals( add.getFaxNumber() ) ) phFax.append( "F:" + add.getFaxNumber () );
		formatAddress.append ( "<phoneFax><![CDATA[" + phFax + "]]></phoneFax>" + "\n" );
		
		formatAddress.append ( "<email><![CDATA[" );
		formatAddress.append ( ( ( add.getEmail() != null ) && ( add.getEmail().trim().length() > 0 ) ) ? "Email: "+ add.getEmail() : "" );     //modified by varma 06 jul 2004
		formatAddress.append ( "]]></email> \n" );

		return formatAddress.toString() ;
	}


	public ClientInfo getClientInfo()
	{
		return clientInfo;
	}

	public void setClientInfo(ClientInfo info)
	{
		clientInfo = info;
		m_clientName = clientInfo.getClientName();
	}

	public String getClientName()
	{
		return m_clientName;
	}	

	public String getClientAddressObjectFormatted()
	{
		return getFormattedClientAddress( clientInfo.getAddress() );
	}

	public String getClientAddressObjectFormattedAirgo()
	{
		StringBuffer formattedString = new StringBuffer();
		
		if( clientInfo != null && clientInfo.getClientName() != null && clientInfo.getClientName().trim().length() > 0	 )
		{		
			if( clientInfo.getAddress() != null && ( ( clientInfo.getAddress().getAddress1() != null && clientInfo.getAddress().getAddress1().trim().length() > 0 ) || ( clientInfo.getAddress().getAddress2() != null && clientInfo.getAddress().getAddress2().trim().length() > 0 ) ) )
			{
				formattedString.append( "<br>" );
			}
		}
 		formattedString.append( getFormattedAddressAirgo( clientInfo.getAddress() ) );
		return formattedString.toString(); 
	}
	
    public String getClientAddrWithOutEmailObjFormatted()
	{
        Address add = clientInfo.getAddress();
        StringBuffer formatAddress = new StringBuffer();

        formatAddress.append ( ( ( add.getAddress1() == null ) || ( ( add.getAddress1().trim().length() == 0 ) ) ) ? "" :"<BR>" +  add.getAddress1() );
        formatAddress.append ( ( ( add.getAddress2() == null ) || ( ( add.getAddress2().trim().length() == 0 ) ) ) ? "" :"<BR>" + add.getAddress2() );
        formatAddress.append ( ( ( add.getAddress3() == null ) || ( ( add.getAddress3().trim().length() == 0 ) ) ) ? "" : "<BR>" + add.getAddress3() );
        formatAddress.append ( ( ( add.getAddress4() == null ) || ( ( add.getAddress4().trim().length() == 0 ) ) ) ? "" : "<BR>" + add.getAddress4() );
        //formatAddress.append ( ( ( add.getCity() == null ) || ( add.getCity().trim().length()==0 ) ) ? "" : "<BR>" +  add.getCity() );
        String formatState = PackingSlipForm.getFormatedCityState(add);
        if ( formatState.trim().length() !=0 )
           formatAddress.append ("<BR>"+formatState);
        formatAddress.append ( ( ( add.getPhoneNumber() != null ) && ( add.getPhoneNumber().trim().length() > 0 ) ) ?  "<BR>Tel: "+ add.getPhoneNumber() : "" );
        formatAddress.append ( ( ( add.getFaxNumber() != null ) && ( add.getFaxNumber().trim().length() > 0 ) ) ?  "<BR>Fax: "+ add.getFaxNumber() : "" );

        return formatAddress.toString() ;
	}
	
	public String getClientAddrWithOutEmailObjFormattedAirgo()
	{
		Address add = clientInfo.getAddress();
		StringBuffer formatAddress = new StringBuffer();
		
		if( add != null )
		{
			if( clientInfo.getClientName() != null && clientInfo.getClientName().trim().length() > 0 )
			{
				if( ( add.getAddress1() != null && !"".equalsIgnoreCase( add.getAddress1().trim() ) ) || ( add.getAddress2() != null && !"".equalsIgnoreCase( add.getAddress2().trim() ) ) )
				{
					formatAddress.append ( "<BR>" );
				}
			}
		
			if( add.getAddress1() != null && !( add.getAddress1().trim().length() == 0 ) )
			formatAddress.append ( add.getAddress1().trim() );
		
			if( ( add.getAddress1() != null && !( add.getAddress1().trim().length() == 0 ) ) && ( add.getAddress2() != null && !( add.getAddress2().trim().length() == 0 ) ) )
			formatAddress.append ( ", " );
		
			if( add.getAddress2() != null && !( add.getAddress2().trim().length() == 0 ) )
			formatAddress.append ( add.getAddress2().trim() ); 

			if( ( add.getAddress3() != null && !"".equalsIgnoreCase( add.getAddress3().trim() ) ) || ( add.getAddress4() != null && !"".equalsIgnoreCase( add.getAddress4().trim() ) ) )
			formatAddress.append ( "<BR>" );
		
			if( ( add.getAddress3() != null && !"".equalsIgnoreCase( add.getAddress3().trim() ) ) )
			formatAddress.append ( add.getAddress3().trim() );
		
			if( add.getAddress3() != null && !"".equalsIgnoreCase( add.getAddress3().trim() ) && add.getAddress4() != null && !"".equalsIgnoreCase( add.getAddress4().trim() ) )
			formatAddress.append ( ", " );
		
			if( ( add.getAddress4() != null && !"".equalsIgnoreCase( add.getAddress4().trim() ) ) )
			formatAddress.append ( add.getAddress4().trim() ); 

			StringBuffer cityStateZip = new StringBuffer ( "" );

			if ( add.getCity() != null && !"".equals ( add.getCity().trim() ) ) cityStateZip.append ( add.getCity().trim() );
		
			// add ',' only if city, state, zip are not empty  
			if ( add.getCity() != null && !"".equals ( add.getCity().trim() ) && ( ( add.getState() != null && !"".equals( add.getState().trim() ) ) || ( add.getZipCode() != null && !"".equals( add.getZipCode().trim() ) ) ) ) cityStateZip.append ( ", " );
		
			if ( add.getState() != null && !"".equals( add.getState().trim() ) ) cityStateZip.append( add.getState().trim() );
		
			// Add '-' only if there is state and Zip also
			if ( add.getState() != null && !"".equals( add.getState().trim() ) && add.getZipCode() != null && !"".equals( add.getZipCode().trim() ) ) cityStateZip.append ( " - " );
		
			if ( add.getZipCode() != null && !"".equals ( add.getZipCode().trim() ) ) cityStateZip.append ( add.getZipCode ().trim() );
		
			// add ',' if any of the above is present
			if ( ( ( add.getCity() != null && !"".equals( add.getCity().trim() ) ) || !"".equals( add.getState().trim() ) || !"".equals ( add.getZipCode() ) ) && !"".equalsIgnoreCase( add.getCountry () ) ) cityStateZip.append ( ", " );
			cityStateZip.append ( add.getCountry () );

			if( cityStateZip.toString().trim().length() > 0  )
			{
				formatAddress.append ( "<BR>" + cityStateZip );	
			}

			StringBuffer phFax = new StringBuffer ();
			if( add.getPhoneNumber() != null && !"".equals( add.getPhoneNumber().trim() ) ) phFax.append ( "T:" + add.getPhoneNumber().trim() );
			if( add.getPhoneNumber() != null && !"".equals( add.getPhoneNumber().trim() ) && add.getFaxNumber() != null && !add.getFaxNumber().equals ( "" ) ) phFax.append ( ",&nbsp;" );
			if( add.getFaxNumber() != null && !"".equals( add.getFaxNumber().trim() ) ) phFax.append ( "F:" + add.getFaxNumber().trim() );
		
			if( phFax.toString().trim().length() > 0  )
			{
				formatAddress.append ( "<BR>" + phFax );	
			}
		}
		return formatAddress.toString() ;
	}


    public String getLabelClientAddressObjectFormatted()
	{
		return getLabelFormattedClient ( clientInfo.getAddress() );
	}

	public String getClientAddressXMLFormatted()
	{
		return getXMLFormattedClientAddress( clientInfo.getAddress() );
	}

    public String getShipFromAddressXMLFormatted()
    {
        return getXMLFormattedAddress( clientInfo.getAddress() );
    }

	public String getClientAddressXMLFormattedAirgo()
	{
		return getXMLFormattedAddressAirgo( clientInfo.getAddress() );
	}

	public String getBillingAddressXMLFormattedAirgo()
	{
		return getXMLFormattedAddressAirgo( m_billingAddressObject );
	}

    public String getShippersAddressXMLFormattedAirgo()
	{
		return getXMLFormattedAddressAirgo( m_shippersAddressObject );
	}

	public boolean isConfrimPackingSlip()
	{
		return confrimPackingSlip;
	}

	public void setConfrimPackingSlip( boolean confrim )
	{
		confrimPackingSlip = confrim;
	}

	public boolean isCancelPackingSlip()
	{
		return cancelPackingSlip;
	}

	public void setCancelPackingSlip(boolean b)
	{
		cancelPackingSlip = b;
	}

    public int getCstRandomKey() {
        return m_cstRandomKey;
    }

    public void setCstRandomKey(int cstRandomKey) {
        this.m_cstRandomKey = cstRandomKey;
    }

    public String getCustomerNumber() {
        return customerNumber;
    }

    public void setCustomerNumber(String customerNumber) {
        this.customerNumber = customerNumber;
    }

    public String getRecipientType() {
        return recipientType;
    }

    public void setRecipientType(String recipientType) {
        this.recipientType = recipientType;
    }

    public String getPaletteCount(){
        return mPaletteCount;
    }
    public void setPaletteCount( String paletteCount ){
        this.mPaletteCount = paletteCount;
    }

    public String getPackedby()  //Added by Gandhi on 8th Dec 2004
    {
        return mPackedby;
    }

    public void setPackedby( String packedby )
    {
        mPackedby = packedby;
    }

    public String getTitle()  //Added by Gandhi on 8th Dec 2004
    {
        return mTitle;
    }

    public void setTitle( String title )
    {
        mTitle = title;
    }

	public String getVendorName()
	{
		return vendorName;
	}

	public String getVendorNumber()
	{
		return vendorNumber;
	}

	public void setVendorName(String string)
	{
		vendorName = string;
	}

	public void setVendorNumber(String string)
	{
		vendorNumber = string;
	}
    public String getSupplierNumber() {
            return supplierNumber;
    }

    public void setSupplierNumber(String supplierNumber) {
        this.supplierNumber = supplierNumber;
    }

    public String getOdmSupplierNumber() {
        return odmSupplierNumber;
    }

    public void setOdmSupplierNumber(String odmSupplierNumber) {
        this.odmSupplierNumber = odmSupplierNumber;
    }

    public String getOdm() {
        return odm;
    }

    public void setOdm(String odm) {
        this.odm = odm;
    }

    public int getOdmId() {
        return odmId;
    }

    public void setOdmId(int odmId) {
        this.odmId = odmId;
    }

    public String getResponseStatus() {
        return responseStatus;
    }

    public void setResponseStatus(String responseStatus) {
        this.responseStatus = responseStatus;
    }

    public Address getShippersAddressObject() {
        return m_shippersAddressObject;
    }

    public void setShippersAddressObject(Address shippersAddressObject) {
        this.m_shippersAddressObject = shippersAddressObject;
    }

    public Address getNewShippingAddress() {
        return newShippingAddress;
    }

    public void setNewShippingAddress(Address newShippingAddress) {
        this.newShippingAddress = newShippingAddress;
    }

    public int getNewShippingAddressId() {
        return newShippingAddressId;
    }

    public void setNewShippingAddressId(int newShippingAddressId) {
        this.newShippingAddressId = newShippingAddressId;
    }

    public int getNewHiddenShippingAddressId() {
        return newHiddenShippingAddressId;
    }

    public void setNewHiddenShippingAddressId(int newHiddenShippingAddressId) {
        this.newHiddenShippingAddressId = newHiddenShippingAddressId;
    }

    public String getShippersAddressObjectFormattedAirgo()
	{
		StringBuffer formatedAddress = new StringBuffer();
		formatedAddress.append( getFormattedAddressAirgo( m_shippersAddressObject ) );
		return formatedAddress.toString();
	}

    public String getFreightInstructions()
    {
        return freightInstructions;
    }

    public String getFreightInstructionsObjectFormatted()
    {
        return formatLines( freightInstructions, 50 );
    }

    public void setFreightInstructions(String freightInstructions) {
        this.freightInstructions = freightInstructions;
    }

    public String getLetterOfCreditNo() {
        return letterOfCreditNo;
    }

    public void setLetterOfCreditNo(String letterOfCreditNo) {
        this.letterOfCreditNo = letterOfCreditNo;
    }

    public Address getShippingVendorAddressObject() {
        return shippingVendorAddressObject;
    }

    public void setShippingVendorAddressObject(Address shippingVendorAddressObject) {
        this.shippingVendorAddressObject = shippingVendorAddressObject;
    }

    public String getShippingVendorAddressXMLFormatted()
	{
		return getXMLFormattedAddress( shippingVendorAddressObject );
	}

    String formatLines( String targetString, int maxLength )
    {
        String formatedString = "";
        if( targetString != null && targetString.trim().length() > 0 )
        {
            for ( int i = 0; i < targetString.length(); i++ )
            {
                if( ( ( i + 1 ) % maxLength ) == 0 )
                {
                    formatedString = formatedString + "<br>&nbsp;";
                    formatedString = formatedString + targetString.substring( i, i + 1 );
                }
                else
                {
                    formatedString = formatedString + targetString.substring( i, i + 1 );
                }
            }
        }
        return formatedString;
    }


    public boolean isConsignment() {
        return isConsignment;
    }

    public void setConsignment(boolean consignment) {
        isConsignment = consignment;
    }


    public String getWeightType() {
        return weightType;
    }

    public void setWeightType(String weightType) {
        this.weightType = weightType;
    }


    public String getPackageDimension() {
        return packageDimension;
    }

    public void setPackageDimension(String packageDimension) {
        this.packageDimension = packageDimension;
    }

    public String getGrossWeight() {
        return getFormatedWeight ( grossWeight );
    }

    public void setGrossWeight(String grossWeight) {
        this.grossWeight = getFormatedWeight( grossWeight );
    }


    public String getCountryOfFabOrigin() {
        return countryOfFabOrigin;
    }

    public void setCountryOfFabOrigin(String countryOfFabOrigin) {
        this.countryOfFabOrigin = countryOfFabOrigin;
    }

    public String getCountryOfAssyOrigin() {
        return countryOfAssyOrigin;
    }

    public void setCountryOfAssyOrigin(String countryOfAssyOrigin) {
        this.countryOfAssyOrigin = countryOfAssyOrigin;
    }


    public String getUomPkgDimension() {
        return uomPkgDimension;
    }

    public void setUomPkgDimension(String uomPkgDimension) {
        this.uomPkgDimension = uomPkgDimension;
    }


    public String getFlightNumberOne() {
        return flightNumberOne;
    }

    public void setFlightNumberOne(String flightNumberOne) {
        this.flightNumberOne = flightNumberOne;
    }

    public String getFlightNumberTwo() {
        return flightNumberTwo;
    }

    public void setFlightNumberTwo(String flightNumberTwo) {
        this.flightNumberTwo = flightNumberTwo;
    }

    public String getEtd() {
        return etd;
    }

    public void setEtd(String etd) {
        this.etd = etd;
    }

    public String getEta() {
        return eta;
    }

    public void setEta(String eta) {
        this.eta = eta;
    }

    public String getHawb() {
        return hawb;
    }

    public void setHawb(String hawb) {
        this.hawb = hawb;
    }

    public String getMawb() {
        return mawb;
    }

    public void setMawb(String mawb) {
        this.mawb = mawb;
    }

    public int getNewBillingAddressId() {
        return newBillingAddressId;
    }

    public void setNewBillingAddressId(int newBillingAddressId) {
        this.newBillingAddressId = newBillingAddressId;
    }

    public String getAirWayBillNo() {
        return airWayBillNo;
    }

    public void setAirWayBillNo(String airWayBillNo) {
        this.airWayBillNo = airWayBillNo;
    }
}